local function CalculateAimPos(a, b, c, d)
	if not a.x then
		a = a:GetPosition()
	end
	if not b.x then
		b = b:GetPosition()
	end
	if b.x == a.x then
		b.x = b.x + 0.1
	end
	if b.z == a.z then
		b.z = b.z + 0.1
	end
	local dx, dz = b.x - a.x, b.z - a.z
	local distance = math.sqrt(dx * dx + dz * dz)
	local cos, sin = dx / distance, dz / distance
	local aimdx = d * (math.cos(c) * cos - math.sin(c) * sin)
	local aimdz = d * (math.sin(c) * cos + math.cos(c) * sin)
	local aimx, aimz = a.x + aimdx, a.z + aimdz
	return Vector3(aimx, 0, aimz)
end
local function fakeRotateToTarget(self, dest)
	local newpos = CalculateAimPos(self.inst, dest, (math.random() * 45 - 22.5) * DEGREES, 1)
	dest = newpos
	self.dest = dest
	local direction = dest - self.inst:GetPosition()
	direction:Normalize()
	local angle = math.acos(direction:Dot(Vector3(1, 0, 0))) / DEGREES
	self.inst.Transform:SetRotation(angle)
	self.inst:FacePoint(dest)
end
AddPrefabPostInit("blowdart_walrus", function(inst)
	if not TheWorld.ismastersim then
		return
	end
	if inst.components.projectile then
		inst.components.projectile:SetSpeed(10)
		inst.components.projectile:SetRange(15)
		inst.components.projectile.RotateToTarget = fakeRotateToTarget
	end
end)
